/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*-  */
/*
 * liberacus
 * Copyright (C) 2012 Massimiliano Maniscalco <massi.neptune@yahoo.com>
 * 
liberacus is free software: you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by the
 * Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * liberacus is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * See the GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License along
 * with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef _CLIENTE_H_
#define _CLIENTE_H_

#include <gtkmm.h>
#include <iostream>
#include <iomanip>
#include "utility.h"

class Cliente
{
public:
	inline Cliente() : nome ( Glib::ustring ( "" ) ), telefono ( Glib::ustring ( "" ) )
	{}
	inline Cliente ( const Glib::ustring &str_n, const Glib::ustring &str_t ) : nome ( str_n ), telefono ( str_t )
	{}
	inline Cliente& operator=( const Cliente &clt );
	inline bool operator<( const Cliente &clt ) const;
	inline bool operator==( const Cliente &clt ) const;
	inline void set_nome ( const Glib::ustring &str ) { nome.assign ( str ); }
	inline Glib::ustring get_nome ( void ) const { return nome; }
	inline void set_telefono ( const Glib::ustring &str ) { telefono.assign ( str ); }
	inline Glib::ustring get_telefono ( void ) const { return telefono; }
	inline void clean_up ( void );
	inline Glib::ustring get_xml_string ( void ) const;

protected:

private:
	Glib::ustring nome;
	Glib::ustring telefono;

};

inline Cliente& Cliente::
operator=( const Cliente &clt )
{
	if ( this != &clt )
	{
		nome = clt.nome;
		telefono = clt.telefono;
	}
	return *this;
}

inline bool Cliente::
operator<( const Cliente &clt ) const
{
	if ( nome.raw () < clt.nome.raw () )
		return true;
	return false;
}

inline bool Cliente::
operator==( const Cliente &clt ) const
{
	if ( nome.raw () == clt.nome.raw () )
		return true;
	return false;
}

inline void Cliente::
clean_up ( void )
{
	nome.assign( "" );
	telefono.assign( "" );
}

inline Glib::ustring Cliente::
get_xml_string ( void ) const
{
	Glib::ustring str;
	str.append ( Glib::ustring ( "<cliente>\n" ) );
	str.append ( Glib::ustring ( "\t<nome>" + msu::get_xml_friendly_string(nome) + "</nome>\n" ) );
	if ( telefono != Glib::ustring ( "" ) )
		str.append ( Glib::ustring ( "\t<telefono>" + msu::get_xml_friendly_string(telefono) + "</telefono>\n" ) );
	str.append ( Glib::ustring ( "</cliente>\n" ) );
	return str;
}

#endif // _CLIENTE_H_

